home *** CD-ROM | disk | FTP | other *** search
- <?xml version="1.0" encoding="utf-8" ?>
- <!DOCTYPE stack PUBLIC "-//Apple, Inc.//DTD stack V 2.0//EN" "" >
- <stack>
- <name>in</name>
- <id>-1</id>
- <cardCount>34</cardCount>
- <cardID>9877</cardID>
- <listID>18180</listID>
- <cantModify><false /></cantModify>
- <cantDelete><false /></cantDelete>
- <cantAbort><false /></cantAbort>
- <cardSize>
- <width>512</width>
- <height>342</height>
- </cardSize>
- <script>--Copyright ©1988 - Scott McGilliard - all rights reserved
- --Thank you to: Andrew Gilmartin (Brown University) for XFCN PopUpMenu
-
- on openStack
- global saveMsg
- hide msg
- hide menuBar
- put loc of msg into saveMsg
- push card "Expenses"
- get card field "allExpenses" of card "whichMonths"
- if it = empty then exit openStack
- get the date
- convert it to seconds
- if it >= line 2 of card field "startMonth" of¬
- card "Year Totals" then
- answer "It's time to recalculate, do it now?" with "No" or "Yes"
- if it is "Yes" then
- put last word of the long date into whichYear
- if word 1 of item 2 of the long date ≠ "January" then put " -" &&¬
- whichYear + 1 after whichYear
- set loc of msg to 19,106
- put "Estimating expenses for" && whichYear & ", please wait."
- get line 2 of card field "startMonth" of card "Year Totals"
- convert it to long date
- add 1 to last item of it
- convert it to seconds
- put it into line 2 of card field "startMonth" of¬
- card "Year Totals"
- doEstimate
- doMath
- hide msg
- end if
- end if
- end openStack
-
- on idle
- global moreExpenses
- if moreExpenses = 1 then addExpense
- set cursor to 5
- pass idle
- end idle
-
- on helpIndex
- visual venetian blinds to gray
- visual venetian blinds
- go card "HelpIndex"
- end helpIndex
-
- on addExpense
- global expenseAmount,expense,moreExpenses
- push card
- Get card field "allExpenses" of card "whichMonths"
- if the number of lines of it >= 48 then
- answer "You can not enter more than 48 items" with "OK"
- get field expense3 of card "Expenses"
- if line 16 of it = empty then noMore
- put empty into moreExpenses
- exit addExpense
- end if
- set numberFormat to "0.00"
- repeat forever
- ask "Please enter an expense item"
- repeat
- if "," is in it then
- put offset (",",it) into er
- delete char er of it
- else
- exit repeat
- end if
- end repeat
- put it into expenseItem
- if expenseItem = empty then exit repeat
- if the length of expenseItem > 18 then
- answer "Expense items can have only 18 characters" with "OK"
- exit addExpense
- end if
- put expenseItem&"," into expense
- answer "Do you pay the same amount every time?" with "No" or "Yes"
- if it is "yes" then
- repeat forever
- ask "Please enter the amount for"&&expenseItem
- if it is empty then
- answer "Do you want to delete this expense?" with¬
- "Yes" or "No"
- if it is "yes" then
- put empty into expense
- exit repeat
- else
- next repeat
- end if
- else
- exit repeat
- end if
- end repeat
- if expense = empty then next repeat
- put "$" into expenseAmount
- if char 1 of it = "$" then delete char 1 of it
- repeat
- if "," is in it then
- put offset (",",it) into er
- delete char er of it
- else
- exit repeat
- end if
- end repeat
- add 0 to it
- put it & "," after expenseAmount
- put expenseAmount after expense
- answer "Do you pay this expense every month?" with "No" or "Yes"
- else
- put "variable," into expenseAmount
- put expenseAmount after expense
- end if
- if it is "yes" and expenseAmount Γëá "variable," then
- put "Every Month" after expense
- exit repeat
- else
- visual venetian blinds to gray
- visual venetian blinds
- go card "whichMonths"
- put empty into moreExpenses
- exit addExpense
- end if
- end repeat
- doAlphabet
- answer "Are you finished adding expenses?" with "Yes" or "No"
- if it = "yes" then
- put the number of lines of card field "allExpenses"¬
- of card "whichMonths" into test1
- put the number of lines of field "expense" of card "Expenses"¬
- into test2
- add the number of lines of field "expense2" of card "Expenses"¬
- to test2
- add the number of lines of field "expense3" of card "Expenses"¬
- to test2
- if test2 < test1 then
- noMore
- else
- put empty into moreExpenses
- end if
- end if
- end addExpense
-
- on doAlphabet
- global expense
- set cursor to 4
- set loc of msg to 19,106
- put "Please wait"
- if expense = empty then
- hide msg
- exit doAlphabet
- end if
- repeat with x = 1 to the length of item 1 of expense
- put the charToNum of char x of item 1 of expense into temp
- if temp >= 97 and temp <= 122 then
- put temp - 32 into temp
- put the numToChar of temp into char x of item 1 of expense
- end if
- end repeat
- put card field "allExpenses" of card "whichMonths" into allExpenses
- if allExpenses = empty then
- put expense into card field "allExpenses" of card "whichMonths"
- put empty into expense
- hide msg
- exit doAlphabet
- end if
- put item 1 of expense into ex
- put 1 into y
- put 1 into z
- repeat
- if ex = item 1 of line y of allExpenses then
- answer "You can't enter the same expense item twice." with "OK"
- ask "Please enter a different name for" && ex
- if it = ex or it = empty then
- put empty into expense
- hide msg
- exit doAlphabet
- else
- repeat
- if "," is in it then
- put offset (",",it) into er
- delete char er of it
- else
- exit repeat
- end if
- end repeat
- put it into ex
- repeat
- if the length of ex > 18 then
- delete last char of ex
- else
- exit repeat
- end if
- end repeat
- repeat with x = 1 to the length of ex
- put the charToNum of char x of ex into temp
- if temp >= 97 and temp <= 122 then
- put temp - 32 into temp
- put the numToChar of temp into char x of ex
- end if
- end repeat
- put ex into item 1 of expense
- put 1 into y
- put 1 into z
- end if
- end if
- if line y of allExpenses = empty then
- put return & expense after last line of card field "allExpenses"¬
- of card "whichMonths"
- put empty into expense
- hide msg
- exit doAlphabet
- end if
- if the charToNum of char z of ex = the charToNum of char z¬
- of item 1 of line y of allExpenses then
- add 1 to z
- if char z of item 1 of line y of allExpenses = empty then
- add 1 to y
- put 1 into z
- next repeat
- end if
- if char z of ex = empty then
- put expense & return before line y of card field "allExpenses"¬
- of card "whichMonths"
- put empty into expense
- hide msg
- exit doAlphabet
- end if
- next repeat
- end if
- if the charToNum of char z of ex < the charToNum of char z¬
- of item 1 of line y of allExpenses then
- put expense & return before line y of card field "allExpenses"¬
- of card "whichMonths"
- put empty into expense
- hide msg
- exit doAlphabet
- else
- add 1 to y
- put "1" into z
- next repeat
- end if
- end repeat
- hide msg
- end doAlphabet
-
- on noMore
- global moreExpenses
- set loc of msg to 19,106
- put "This will take a couple of minutes, please wait."
- put empty into moreExpenses
- set cursor to 4
- set lockScreen to true
- put card field "allExpenses" of card "whichMonths" into allExpenses
- repeat with x = 2 to 13
- put empty into field expense of card x
- put empty into field amount of card x
- put empty into field expense2 of card x
- put empty into field amount2 of card x
- end repeat
- put empty into field expense of card "Expenses"
- put empty into field expense2 of card "Expenses"
- put empty into field expense3 of card "Expenses"
- repeat with i = 1 to the number of lines in allExpenses
- put item 1 of line i of allExpenses into expenseName
- put expenseName & return after field expense of card "Expenses"
- if item 3 of line i of allExpenses = "Every Month" then
- repeat with x = 2 to 13
- put expenseName & return after field expense of card x
- put item 2 of line i of allExpenses & return after field amount¬
- of card x
- end repeat
- else
- if item 2 of line i of allExpenses = "Variable" then
- repeat with x = 3 to the number of items in¬
- line i of allExpenses
- put word 1 of item x of line i of allExpenses into which
- put expenseName & return after field expense of card which
- put last word of item x of line i of allExpenses & return¬
- after field amount of card which
- end repeat
- else
- repeat with x = 3 to the number of items in¬
- line i of allExpenses
- put item x of line i of allExpenses into which
- put expenseName & return after field expense of card which
- put item 2 of line i of allExpenses & return after field¬
- amount of card which
- end repeat
- end if
- end if
- end repeat
- repeat with x = 2 to 13
- put line 16 to 30 of field expense of card x into field expense2¬
- of card x
- delete line 16 to 30 of field expense of card x
- put line 16 to 30 of field amount of card x into field amount2¬
- of card x
- delete line 16 to 30 of field amount of card x
- end repeat
- put line 17 to 32 of field expense of card "Expenses" into field expense2¬
- of card "Expenses"
- put line 33 to 48 of field expense of card "Expenses" into field expense3¬
- of card "Expenses"
- delete line 17 to 48 of field expense of card "Expenses"
- hide msg
- end noMore
-
- on seeItems
- put card field "allExpenses" of card "whichMonths" into allExpenses
- put (item 2 of the clickLoc - 39) div 16 into whichLine
- put the short name of the target into whichField
- if line whichLine of field whichField is empty then exit seeItems
- get line whichLine of field whichField
- repeat with i = 1 to the number of lines in allExpenses
- if it = item 1 of line i of allExpenses then
- put line i of allExpenses into theList
- exit repeat
- end if
- end repeat
- if item 3 of theList = "Every Month" then put "," & card¬
- field "monthList" of card "Expenses" after theList
- put the mouseloc into listHere
- put item 1 of listHere + 1 into horiz
- put item 2 of listHere - 10 into vert
- get the number of items in theList
- put vert + (it * 17) into length
- if length > 314 then subtract (length - 324) from vert
- get PopUpMenu(theList, 1, vert, horiz)
- put item it of theList into whatCard
- if it = 1 then
- visual barn door close slowly to gray
- visual barn door open slowly
- go card whatCard
- if the result Γëá empty then
- repeat
- answer "Automatic cost adjustment for this expense?" with "Help"¬
- or "Yes" or "No"
- if it = "Help" then
- push card
- visual venetian blinds
- go card it
- show card field "Cost"
- repeat until the mouse is down
- end repeat
- visual venetian blinds
- pop card
- else
- exit repeat
- end if
- end repeat
- if it = "Yes" then
- go card "template"
- doMenu "New Card"
- put item 1 of theList into bill
- set name of this card to bill
- put "," & bill after line 3 of card field "startMonth" of card¬
- "Year Totals"
- repeat with y = 1 to the number of fields
- put field y of card "template" into field y of card bill
- end repeat
- put bill into field "title" of card bill
- put field "months" of card bill into tempMon
- set numberFormat to "0.00"
- if item 3 of theList = "Every Month" then
- set numberFormat to "0"
- ask "Enter amount for"&& bill && "in" && last item¬
- of the long date - 1 with item 2 of theList
- set numberFormat to "0.00"
- repeat
- if "," is in it then
- put offset (",",it) into er
- delete char er of it
- else
- exit repeat
- end if
- end repeat
- if it = empty then put item 2 of the list into it
- if char 1 of it = "$" then delete char 1 of it
- add 0 to it
- put "$" before it
- repeat with y = 1 to 12
- put item 2 of theList into line y of act
- put it into line y of amo
- end repeat
- else
- if item 2 of theList = "variable" then
- put theList into oldList
- repeat with i = 3 to the number of items in theList
- ask "Enter amount for 1 yr before last" && word 1 of¬
- item i of theList with last word of item i of theList
- repeat
- if "," is in it then
- put offset (",",it) into er
- delete char er of it
- else
- exit repeat
- end if
- end repeat
- if it = empty then put last word of item i of¬
- theList into it
- if char 1 of it = "$" then delete char 1 of it
- add 0 to it
- put "$" before it
- repeat with x = 1 to 12
- if word 1 of item i of theList = line x of¬
- tempMon then exit repeat
- end repeat
- put last word of item i of theList into line x of act
- put it into line x of amo
- end repeat
- else
- put theList into oldList
- set numberFormat to "0"
- ask "Enter amount for"&& bill && "in" && last item¬
- of the long date - 1 with item 2 of theList
- repeat
- if "," is in it then
- put offset (",",it) into er
- delete char er of it
- else
- exit repeat
- end if
- end repeat
- set numberFormat to "0.00"
- if it = empty then put item 2 of the list into it
- if char 1 of it = "$" then delete char 1 of it
- add 0 to it
- put "$" before it
- repeat with i = 3 to the number of items in theList
- repeat with x = 1 to 12
- if word 1 of item i of theList = line x of¬
- tempMon then exit repeat
- end repeat
- put item 2 of theList into line x of act
- put it into line x of amo
- end repeat
- end if
- set cursor to 4
- end if
- put act into field "actual" of card bill
- put amo into field "amount" of card bill
- put "0" into totalAct
- put "0" into totalAmo
- repeat with y = 1 to 12
- delete char 1 of line y of act
- delete char 1 of line y of amo
- add line y of act to totalAct
- add line y of amo to totalAmo
- end repeat
- set numberFormat to "0.0"
- put ((totalAct - totalAmo)/totalAmo)*100 into inc
- if inc < 0 then put 0 into inc
- put inc & "%" into line 2 of field "increase" of card bill
- set numberFormat to "0.00"
- repeat with y = 1 to 12
- if line y of act Γëá empty then
- put "$" & line y of amo + (line y of amo * inc/100) into¬
- line y of pro
- put "$" & line y of amo - (line y of amo * inc/100) into¬
- line y of bas
- end if
- end repeat
- put pro into field "projected" of card bill
- put bas into field "base" of card bill
- if item 2 of theList = "Variable" then
- get word 1 of item 2 of the long date
- repeat with i = 1 to 12
- if it = line i of tempMon then exit repeat
- end repeat
- put i into t
- repeat with i = i to 12
- put line i of field "actual" of card bill into line i of¬
- field "amount" of card bill
- put line i of field "amount" of card bill into line i of¬
- field "base" of card bill
- if line i of act Γëá empty then
- put "$" & line i of act + (line i of act * inc/100) into¬
- line i of field "projected" of card bill
- put "$" & line i of act - (line i of act * inc/100) into¬
- line i of field "base" of card bill
- end if
- put empty into line i of field "actual" of card bill
- end repeat
- repeat
- answer "Estimate" && bill && "and recalculate?" with "Help"¬
- or "Yes" or "No"
- if it = "Help" then
- push card
- visual venetian blinds
- go card it
- show card field "Estimate"
- repeat until the mouse is down
- end repeat
- visual venetian blinds
- pop card
- else
- exit repeat
- end if
- end repeat
- if it is "Yes" then
- set loc of msg to 19,106
- put "Estimating expense, please wait."
- repeat with t = t to 12
- get line t of field "amount" of card bill
- if it Γëá empty then
- put line t of field "projected" of card bill into proAm
- put proAm into line t of field "actual" of card bill
- put line t of tempMon into¬
- whichMonth
- repeat with s = 1 to the number of items in theList
- if whichMonth is in item s of theList then exit repeat
- end repeat
- put proAm into last word of item s of theList
- repeat with y = 1 to 3
- if bill is in field y of card whichMonth then
- repeat with i = 1 to the number of lines in field y¬
- of card whichMonth
- if bill = line i of field y of card¬
- whichMonth then
- put proAm into line i of field (y + 1) of¬
- card whichMonth
- exit repeat
- end if
- end repeat
- exit repeat
- end if
- end repeat
- repeat with i = 1 to the number of lines in allExpenses
- if bill = item 1 of line i of allExpenses then
- put theList into line i of card field "allExpenses"¬
- of card "whichMonths"
- exit repeat
- end if
- end repeat
- end if
- end repeat
- doMath
- end if
- end if
- end if
- end if
- else
- if whatCard = "Every Month" then
- answer "You can't go to every month at once." with "OK"
- exit seeItems
- else
- put word 1 of whatCard into whatCard
- end if
- visual barn door close slowly to gray
- visual barn door open slowly
- go card whatCard
- end if
- end seeItems
-
- on doEstimate
- set cursor to 4
- put last word of the long date into whichYear
- if word 1 of item 2 of the long date ≠ "January" then put " -" &&¬
- whichYear + 1 after whichYear
- put whichYear into field "thisYear1" of card "template"
- put whichYear into field "thisYear2" of card "template"
- put "SUMMARY FOR" && whichYear into card field "title"¬
- of card "Year Totals"
- if whichYear = last word of the long date then
- put whichYear - 1 into field "lastYear" of card "template"
- else
- subtract 1 from first word of whichYear
- subtract 1 from last word of whichYear
- put whichYear into field "lastYear" of card "template"
- end if
- put card field "allExpenses" of card "whichMonths" into allExpenses
- put line 3 of card field "startMonth" of card "Year Totals" into¬
- whichBill
- put field "months" of card "template" into tempMon
- repeat with i = 2 to the number of items in whichBill
- put item i of whichBill into bill
- repeat with x = 1 to the number of lines in allExpenses
- if bill = item 1 of line x of allExpenses then
- put line x of allExpenses into theList
- exit repeat
- end if
- end repeat
- put field "thisYear1" of card "template" into field "thisYear1"¬
- of card bill
- put field "thisYear2" of card "template" into field "thisYear2"¬
- of card bill
- put field "lastYear" of card "template" into field "lastYear"¬
- of card bill
- put field "amount" of card bill into amo
- put field "actual" of card bill into act
- put field "projected" of card bill into pro
- repeat with y = 1 to 12
- if line y of amo ≠ empty and line y of act = empty then put¬
- line y of pro into line y of act
- end repeat
- if item 2 of theList Γëá "Variable" then
- repeat with y = 1 to 12
- if line y of act Γëá empty then
- put line y of act into test
- exit repeat
- end if
- end repeat
- repeat with y = 1 to 12
- if line y of act ≠ empty and line y of act ≠¬
- test then exit repeat
- end repeat
- repeat with z = y to 12
- if line z of amo Γëá empty then put test into line z of amo
- end repeat
- put amo into field "base" of card bill
- put act into field "amount" of card bill
- repeat with z = 1 to y - 1
- if line z of act Γëá empty then
- put line y of act into line z of act
- put line y of act into line z of field "projected"¬
- of card bill
- end if
- end repeat
- put line y of act into test2
- delete char 1 of test
- delete char 1 of test2
- set numberFormat to "0.0"
- put ((test2 - test)/test)*100 into inc
- if inc < 0 then put 0 into inc
- put inc & "%" into line 2 of field "increase" of card bill
- set numberFormat to "0.00"
- repeat with z = y to 12
- if line z of amo Γëá empty then
- delete char 1 of line z of act
- put "$" & line z of act + (line z of act * inc/100) into¬
- line z of field "projected" of card bill
- put "$" & line z of act + (line z of act * inc/100) into¬
- item 2 of theList
- end if
- put empty into line z of act
- end repeat
- put act into field "actual" of card bill
- else
- put amo into field "base" of card bill
- put act into field "amount" of card bill
- put empty into field "actual" of card bill
- put "0" into totalAct
- put "0" into totalAmo
- repeat with y = 1 to 12
- delete char 1 of line y of act
- delete char 1 of line y of amo
- add line y of act to totalAct
- add line y of amo to totalAmo
- end repeat
- set numberFormat to "0.0"
- put ((totalAct - totalAmo)/totalAmo)*100 into inc
- if inc < 0 then put 0 into inc
- put inc & "%" into line 2 of field "increase" of card bill
- set numberFormat to "0.00"
- repeat with y = 1 to 12
- if line y of amo ≠ empty then put "$" & line y of¬
- act + (line y of act * inc/100) into line y of¬
- field "projected" of card bill
- end repeat
- end if
- repeat with t = 1 to 12
- get line t of field "projected" of card bill
- if it Γëá empty then
- put it into proAm
- put line t of tempMon into whichMonth
- if item 2 of theList = "variable" then
- repeat with s = 1 to the number of items in theList
- if whichMonth is in item s of theList then exit repeat
- end repeat
- put proAm into last word of item s of theList
- end if
- repeat with y = 1 to 3
- if bill is in field y of card whichMonth then
- repeat with i = 1 to the number of lines in field y¬
- of card whichMonth
- if bill = line i of field y of card¬
- whichMonth then
- put proAm into line i of field (y + 1) of¬
- card whichMonth
- exit repeat
- end if
- end repeat
- exit repeat
- end if
- end repeat
- repeat with i = 1 to the number of lines in allExpenses
- if bill = item 1 of line i of allExpenses then
- put theList into line i of card field "allExpenses"¬
- of card "whichMonths"
- exit repeat
- end if
- end repeat
- end if
- end repeat
- end repeat
- end doEstimate
-
- on doMath
- set cursor to 4
- set loc of msg to 19,106
- put "Calculating, please wait."
- set numberFormat to "0.00"
- put "0" into temp4
- repeat with x = 2 to 13
- put "0" into temp2
- repeat with i = 1 to the number of lines in field 2 of card x
- put line i of field 2 of card x into temp1
- delete char 1 of temp1
- add temp1 to temp2
- end repeat
- repeat with i = 1 to the number of lines in field 4 of card x
- put line i of field 4 of card x into temp1
- delete char 1 of temp1
- add temp1 to temp2
- end repeat
- put "$" & temp2 into field "subTotal" of card x
- put "$" & temp2 & return after temp3
- put temp2 & return after tempAm
- add temp2 to temp4
- end repeat
- put temp3 into card field "amounts" of card "Year Totals"
- put "$" & temp4 into card field "Total" of card "Year Totals"
- put temp4 into